//
//  XingZuoViewController.m
//  基本框架
//
//  Created by runone02 on 2018/8/24.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "XingZuoViewController.h"
#import "DQBirthDateView.h"
#import "DQconstellationView.h"
#import "DQAgeModel.h"
#import "CalculateTool.h"

@interface XingZuoViewController ()<DQBirthDateViewDelegate,DQconstellationViewDelegate>
@property (nonatomic, strong)  UILabel *ageLab;
@property (nonatomic, strong)  UILabel *ConstellationLab;

@property (nonatomic, strong) DQBirthDateView *DQBirthView;
@property (nonatomic, strong) DQconstellationView *DQconstellationView;

@end

@implementation XingZuoViewController

- (void)label{
    self.ageLab = [[UILabel alloc]init];
    self.ageLab.text = @"年龄";
    self.ageLab.textColor = [UIColor blackColor];
    self.ageLab.font = TITLE_FONT(30);
    self.ageLab.userInteractionEnabled = YES;
    self.ageLab.textAlignment = NSTextAlignmentCenter;
    UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ageLabClick)];
    [self.ageLab addGestureRecognizer:labelTapGestureRecognizer];
    [self.view addSubview:self.ageLab];
    
    [self.ageLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).with.offset(kTopBarHeight+40);
        make.left.right.mas_equalTo(self.view);
        make.height.mas_equalTo(40);
    }];
    
    self.ConstellationLab = [[UILabel alloc]init];
    self.ConstellationLab.text = @"星座";
    self.ConstellationLab.textColor = [UIColor blackColor];
    self.ConstellationLab.font = TITLE_FONT(30);
    self.ConstellationLab.userInteractionEnabled = YES;
    self.ConstellationLab.textAlignment = NSTextAlignmentCenter;
    UITapGestureRecognizer *ConstellationLab = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ConstellationLabClick)];
    [self.ConstellationLab addGestureRecognizer:ConstellationLab];
    [self.view addSubview:self.ConstellationLab];
    
    [self.ConstellationLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.ageLab.mas_bottom).with.offset(20);
        make.left.right.mas_equalTo(self.view);
        make.height.mas_equalTo(40);
    }];
}

- (void)ageLabClick{
       [self.DQBirthView startAnimationFunction];
}

- (void)ConstellationLabClick{
     [self.DQconstellationView startAnimationFunction];
}

- (void)setupNavView{
    [self.navView.leftButton setTitle:@"返回" forState:UIControlStateNormal];
    [self.navView.centerButton setTitle:@"计算年龄" forState:UIControlStateNormal];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.DQBirthView = [DQBirthDateView new];
    self.DQBirthView.delegate = self;
    self.DQconstellationView = [DQconstellationView new];
    self.DQconstellationView.delegate = self;
    [self label];
    [self setupNavView];
}


//点击选中哪一行 的代理方法
- (void)clickDQBirthDateViewEnsureBtnActionAgeModel:(DQAgeModel *)ageModel andConstellation:(NSString *)str{
    NSInteger age = [CalculateTool calculateNowAge:ageModel];
    self.ageLab.text = [NSString stringWithFormat:@"%@年 %@月 %@日 %zd岁",ageModel.year,ageModel.month,ageModel.day,age];
    self.ConstellationLab.text = str;
}


//点击选中哪一行 的代理方法
- (void)clickDQconstellationEnsureBtnActionConstellationStr:(NSString *)str{
    self.ConstellationLab.text = str;
}
@end
